import { IPSDEAction } from '../dataentity/action/ipsdeaction';
import { IPSSysTestCase } from './ipssys-test-case';
import { IPSSysTestCaseAssert } from './ipssys-test-case-assert';
import { IPSSysTestCaseInput } from './ipssys-test-case-input';
import { IPSSysTestData } from './ipssys-test-data';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysTestCaseInputImpl extends PSModelObjectImpl implements IPSSysTestCaseInput {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected inputpsdeaction: IPSDEAction | null = null;

  getInputPSDEAction(): IPSDEAction | null {
    if (this.inputpsdeaction != null) return this.inputpsdeaction;
    const value = this.M.getInputPSDEAction;
    if (value == null) {
      return null;
    }
    const ipssystestcase = this.getParentPSModelObject('testing.IPSSysTestCase') as IPSSysTestCase;
    if (ipssystestcase != null) {
      this.inputpsdeaction = ipssystestcase.getPSDataEntityMust().findPSDEAction(value);
    }
    return this.inputpsdeaction;
  }

  get inputPSDEAction(): IPSDEAction | null {
    return this.getInputPSDEAction();
  }

  getInputPSDEActionMust(): IPSDEAction {
    const value = this.getInputPSDEAction();
    if (value == null) {
      throw new Error('未指定输入行为');
    }
    return value;
  }

  get inputTag(): string {
    return this.M.inputTag;
  }

  get inputTag2(): string {
    return this.M.inputTag2;
  }

  get inputTag3(): string {
    return this.M.inputTag3;
  }

  get inputTag4(): string {
    return this.M.inputTag4;
  }

  get inputType(): 'DATA' | 'CUSTOMCODE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.inputType;
  }

  get inputValue(): string {
    return this.M.inputValue;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssystestcaseasserts: IPSSysTestCaseAssert[] | null = null;

  getPSSysTestCaseAsserts(): IPSSysTestCaseAssert[] | null {
    if (this.pssystestcaseasserts == null) {
      const value = this.M.getPSSysTestCaseAsserts;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: IPSSysTestCaseAssert[] = [];
      const ipssystestcase = this.getParentPSModelObject('testing.IPSSysTestCase') as IPSSysTestCase;
      for (let i = 0; i < arrayNode.length; i++) {
        const item = ipssystestcase.findPSSysTestCaseAssert(arrayNode[i]);
        if (item != null) {
          list.push(item);
        }
      }
      this.pssystestcaseasserts = list;
    }
    return this.pssystestcaseasserts.length == 0 ? null : this.pssystestcaseasserts;
  }

  get psSysTestCaseAsserts(): IPSSysTestCaseAssert[] | null {
    return this.getPSSysTestCaseAsserts();
  }

  findPSSysTestCaseAssert(objKey: any): IPSSysTestCaseAssert | null {
    return this.getPSModel5('testing.IPSSysTestCaseAssert', this.getPSSysTestCaseAsserts(), objKey) as IPSSysTestCaseAssert;
  }

  protected pssystestdata: IPSSysTestData | null = null;

  getPSSysTestData(): IPSSysTestData | null {
    if (this.pssystestdata != null) return this.pssystestdata;
    const value = this.M.getPSSysTestData;
    if (value == null) {
      return null;
    }
    this.pssystestdata = this.getPSModel4('testing.IPSSysTestData', value, 'getPSSysTestData') as IPSSysTestData;
    return this.pssystestdata;
  }

  get psSysTestData(): IPSSysTestData | null {
    return this.getPSSysTestData();
  }

  getPSSysTestDataMust(): IPSSysTestData {
    const value = this.getPSSysTestData();
    if (value == null) {
      throw new Error('未指定测试数据');
    }
    return value;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysTestCaseInputImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'testing.IPSSysTestCaseInput') return true;
    return super.instanceof(cls);
  }
}
